/*
 * PaperJetsLogic.h
 *
 *  Created on: 03.02.2013
 *      Author: Kirill Blinov
 *   Copyright: LGPL
 */

#ifndef PAPERJETSLOGIC_H_
#define PAPERJETSLOGIC_H_

#include "../IGameLogic.h"
#include "../../../Visualisator/Camera.h"
#include <SDL/SDL.h>
#include <glm/glm.hpp>

class PaperJetsLogic: public IGameLogic
{
friend class GameLogicFabric;
private:
	bool         letKernelWork;
	CGameCamera* gameCamera;

	SDLKey       keyTranslationMap[SDLK_LAST];

private:
	void ProcessKeys( std::vector<SDLKey> Keys );
	void ProcessMouse( glm::vec2 MouseDelta, glm::vec2 MousePosition, USHORT MouseKeys[MOUSE_KEY_COUNT] );

	PaperJetsLogic(  CGameWorld::CGameWorldUnitIterator* UnitIterator,
			         std::vector<CGameCamera*> mainCamera );
	virtual ~PaperJetsLogic();

public:
	template <class TableContentFirst, class TableContentSecond>
	void LoadDataTable( const GAME_LOGIC_DATA_TABLE_TYPE TableType,
			            const std::vector< std::pair<TableContentFirst, TableContentSecond> > TableContent );

	virtual void ProcessInputMessage( const INPUT_MESSAGE &Message );
	virtual void ProcessUIMessage( const UI_MESSAGE &Message );
	virtual void ProcessKernelEvent(  );

	virtual bool OnKernelFrame();
};

template <class TableContentFirst, class TableContentSecond>
void PaperJetsLogic::LoadDataTable(
		            const GAME_LOGIC_DATA_TABLE_TYPE TableType,
		            const std::vector< std::pair<TableContentFirst, TableContentSecond> > TableContent )
{
	switch ( TableType )
	{
		break; case GAME_LOGIC_DATA_TABLE_KEYS:
		{
			for ( std::vector< std::pair<TableContentFirst, TableContentSecond> >::const_iterator
				  begin = TableContent.begin(), end = TableContent.end();
				  begin != end;
				  begin++ )
			{
				std::pair<TableContentFirst, TableContentSecond> Value = *begin;
				keyTranslationMap[ Value.first ] = Value.second;
			}
		}
		break; default:
		{
			assert( false );
		}
		break;
	}
}

#endif /* PAPERJETSLOGIC_H_ */
